/*
 * Copyright (c) 2016- 2020 qolome.com Inc. All Rights Reserved.
 * ProjectName: qolome-knowledge
 * FileName: Order.java
 * Author: jiangfeng@qolome.com
 * Date: 2020/3/15 下午4:17
 * LastModified: 2020/03/15 16:17:15
 */

package com.qolome.knowledge.design.pattern.strategy.demo.pay;

import com.qolome.utils.web.HttpResult;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;

/**
 * @author Qolome
 * @version V1.0
 * @Description 订单
 * @date 2020年 03月15日 16:17:06
 */
@Slf4j
public class Order {

    private String uid;

    private String orderId;
    private BigDecimal amount;

    public Order(String uid, String orderId, BigDecimal amount) {
        this.uid = uid;
        this.orderId = orderId;
        this.amount = amount;
    }


    public HttpResult pay() {
        return pay(PayStrategy.DEFAULT_PAY);

    }

    public HttpResult pay(String payKey) {

        AbstractPayment abstractPayment = PayStrategy.get(payKey);
        log.info("欢迎使用{}支付",abstractPayment.getName());
        log.info("本次交易金额{}",amount.toString());
        return  abstractPayment.pay(uid,amount);
    }


}
